//
//  FoundDetailViewController.m
//  MMLOOK
//
//  Created by dllo on 15/9/8.
//  Copyright (c) 2015年 武俊娥. All rights reserved.
//

#import "FoundDetailViewController.h"
#import "AsynConnect.h"

@interface FoundDetailViewController ()<UIWebViewDelegate>

@property (nonatomic, retain)NSMutableDictionary *littleDic;
@property (nonatomic, retain)UIWebView *webView;

@end

@implementation FoundDetailViewController

- (void)dealloc
{
    [_webView release];
    [_littleDic release];
    [_foundDic release];
    [super dealloc];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        self.foundDic = [NSMutableDictionary dictionary];
        self.littleDic = [NSMutableDictionary dictionary];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"宝贝详情";
    [self DetailConnection];
    
    // Do any additional setup after loading the view.
}

- (void)DetailConnection
{
    [AsynConnect asynConnectWithUrlstr:[NSString stringWithFormat:@"http://api.liwushuo.com/v2/items/%@", [self.foundDic objectForKey:@"id"]] parmater:nil block:^(NSData *data) {
        
        NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        self.littleDic = [dic objectForKey:@"data"];
        [self creatWebView];
    }];
}

- (void)creatWebView
{
    self.webView = [[[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    _webView.delegate = self;
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[self.littleDic objectForKey:@"url"]]] autorelease];
    [_webView loadRequest:request];
    [self.view addSubview:_webView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
